package com.tgky.ybzb.utils;

import com.tgky.ybzb.neo4j.entity.NodeEntityObj;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author Lixx
 * @date 2024/9/5 19:33
 */
public class ToolUtils {

    /**
     * 给节点列表去重
     * @param nodeList
     * @return
     */
    public static <T> Set<T> fromListToSet(List<T> nodeList){
        Set<T> set=new HashSet<>();
        nodeList.forEach(set::add);
        return set;
    }
    /**
     * 给节点关系列表去重
     */
    public static Set<NodeEntityObj> relationShipListToSet(List<NodeEntityObj> nodeList){
        Set<String> set=new HashSet<>();
        Set<NodeEntityObj> relationSet=new HashSet<>();
        nodeList.forEach(item->{
            if(StringUtils.isNotBlank(item.getSourceId())){
                if(set.add(item.getRelationShipId())){
                    relationSet.add(item);
                }
            }
        });
        return relationSet;
    }

}
